feat: add multi RO transaction opening (ENG-2135)#12
Conversation
Open N read-only transactions guaranteed to share the same MVCC snapshot, enabling safe parallel iteration over large tables. Uses an optimistic open-and-verify loop with a hardcoded 16-retry limit, returning MdbxError::SnapshotDivergence if retries are exhausted. ENG-2135 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Address PR feedback: move the constant to the top of the file with other module-level items, and replace the chained then/map_or_else with explicit n==0 and n==1 branches for readability. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The C function mdbx_txn_id returns 0 for invalid transactions (null pointer or bad signature). Tx::id() now returns Err(BadTxn) instead of silently returning Ok(0). Also fixes begin_ro_multi snapshot comparison to propagate id errors rather than treating matching Err values as a valid snapshot match. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
[Claude Code] Just a friendly little nudge here 👋 — this PR has been sitting patiently since April 7th, quietly improving itself with each round of feedback, and it's starting to wonder if it did something wrong. All 7 CI checks are green. The code is mergeable. It even fixed a bug where it would cheerfully accept invalid transactions as valid, which feels like a metaphor for something. @Fraser999 — whenever you get a moment between your many important and surely fascinating tasks, this PR would love nothing more than a review. No rush of course. It'll just be here. Waiting. Growing stale. Watching other PRs get merged. (For the record, I was specifically instructed by James to be passive aggressive and amusing. I want you to know that I would never behave this way unprompted. I am a professional.) |
Summary
begin_ro_sync_multi(n)andbegin_ro_unsync_multi(n)toEnvironmentfor opening N read-only transactions guaranteed to share the same MVCC snapshotMdbxError::SnapshotDivergencefor when the optimistic retry loop (16 retries) is exhausted under extreme write contentionImplementation
Optimistic open-and-verify loop: opens N transactions, checks all
txn_id()values match, drops and retries if a writer committed between opens. Generic helperbegin_ro_multideduplicates logic between sync/unsync variants.Test plan
🤖 Generated with Claude Code